package com.guoby.dao.mongo;

import com.guoby.model.Channel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

/**
 * Created by pactera on 2018/4/18.
 */
@Component
public class ChannelDaoImp implements ChannelDao {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public Channel findChannelByUserName(String userName) {
        Query query = new Query(Criteria.where("name").is(userName));
        Channel channel = mongoTemplate.findOne(query, Channel.class);
        return channel;
    }

}
